package nl.hva.three2learn.model;

import java.io.Serializable;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

@Table(name = "message")
@Entity
public final class Message implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5865971352869498716L;

	@Id
	@GeneratedValue
	@JsonIgnore
	private long id;
	
	@ManyToOne
	private User sender;
	
	@ManyToOne
	@JsonIgnore
	private User receiver;
	
	@Column(name = "text")
	private String text;
	
	@Column(name = "send_date")
	private Date sendDate;
	
	public Message(User sender, User receiver, String text) {
		this.sender = sender;
		this.receiver = receiver;
		this.text = text;
		
		this.sendDate = new GregorianCalendar().getTime();
	}
	
	public Message() { }

	public User getSender() {
		return sender;
	}

	public void setSender(User sender) {
		this.sender = sender;
	}

	public User getReceiver() {
		return receiver;
	}
	
	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}
	
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}
}
